import sys
import argparse
import logging
import faulthandler
from pathlib import Path

from nodes.Node import Node
from nodes.SourceNode import SourceNode, VideoSourceNode, RtspSourceNode
from nodes.SinkNode import VideoSinkNode, TestSinkNode, PlayerSinkNode, RtmpSinkNode
from nodes.FFVideoWriterNode import FFVideoWriterNode
from nodes.YOLONode import YOLONode
from nodes.SORTTrackNode import SORTTrackNode
from nodes.FlaskSinkNode import image_fetcher,FlaskSinkNode
from nodes.VideoListSourceNode import VideoListSourceNode
#from FishVideoListSourceNode import FishVideoListSourceNode
#from FishSORTTrackNode import FishSORTTrackNode
#from FishFFVideoWriterNode import FishFFVideoWriterNode
#from FishYOLONode import FishYOLONode
#from utils import *
#from FlaskFetcher import fishFetcher

level = logging.DEBUG
logging.basicConfig(level=level)

faulthandler.enable()

def main():
    #CreateSharedMemory(SHM_VIDEO_NAME);

    source = VideoListSourceNode()
    source.listVideos('/home/input')
    source.saveVideoList("/home/output/videolist.txt")


    fsink = FlaskSinkNode()
    fsink.setPort(8042)
    fsink.setFetcher(image_fetcher)

    fsink.setParent(source)

    fsink.start()
    source.start()

    source.join()
    fsink.join()

if __name__ == "__main__":
    main()
